
if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[spOfficesGetListByUserID]') and OBJECTPROPERTY(id, N'IsProcedure') = 1)
drop procedure [spOfficesGetListByUserID]
GO

	
CREATE PROCEDURE spOfficesGetListByUserID
	@UserID int
AS

SELECT
	[Offices].[OfficeID],
	Offices.[OfficeName],
	[OfficeCode],
	[NotifyEmailEnable],
	[SortOrder]
FROM
	[UserOffices] LEFT JOIN Offices ON
	[UserOffices].OfficeID = [Offices].OfficeID 	
WHERE [UserOffices].UserID = @UserID
ORDER BY [SortOrder]

GO

	
 